<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:jsf="http://xmlns.jcp.org/jsf"
                xmlns:f="http://xmlns.jcp.org/jsf/core"
                xmlns:h="http://xmlns.jcp.org/jsf/html"
                xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
                xmlns:p="http://primefaces.org/ui">


    <p:commandButton value="Regresar al Listado" update=":panelContent">
        <f:setPropertyActionListener 
            target="#{navigationController.navigationContent}"
            value="./pages/maintenance/product_view.xhtml"/>
    </p:commandButton>

    <hr />
    <h:form>
        <h1><h:outputText value="Create/Edit"/></h1>
        <p:panelGrid columns="2">
            <p:outputLabel value="Código Producto:" for="productId" />
            <!--<p:outputLabel id="productId" value="#{productController.product.productId}" title="Product Id"/>-->
            <p:inputText id="productId" value="#{productController.product.productId}" title="Name" required="true" requiredMessage="The Id field is required." size="40" onblur="value=value.toUpperCase()"/>
            
            <p:outputLabel value="Categoría:" for="categoryId" />
            <p:selectOneMenu id="categoryId" value="#{productController.product.categoryId}" converter="entityConverter" required="true">
                <f:selectItem itemLabel="Seleccione un Valor" noSelectionOption="true" />
                <f:selectItems value="#{productController.listCategory}" var="category"
                               itemLabel="#{category.name}" itemValue="#{category}"/>
            </p:selectOneMenu>
            <p:outputLabel value="Marca:" for="markId" />
            <p:selectOneMenu id="markId" value="#{productController.product.markId}" converter="entityConverter" required="true">
                <f:selectItem itemLabel="Seleccione un Valor" noSelectionOption="true" />
                <f:selectItems value="#{productController.listMark}" var="mark"
                               itemLabel="#{mark.name}" itemValue="#{mark}"/>
            </p:selectOneMenu>
            <p:outputLabel value="Tipo de Unidad:" for="unitTypeId" />
            <p:selectOneMenu id="unitTypeId" value="#{productController.product.unitTypeId}" converter="entityConverter" required="true">
                <f:selectItem itemLabel="Seleccione un Valor" noSelectionOption="true" />
                <f:selectItems value="#{productController.listUnitType}" var="unitType"
                               itemLabel="#{unitType.name}" itemValue="#{unitType}"/>
            </p:selectOneMenu>
            <p:outputLabel value="Name:" for="name" />
            <p:inputText id="name" value="#{productController.product.name}" title="Name" required="true" requiredMessage="The Id field is required." size="40" onblur="value=value.toUpperCase()"/>
            <p:outputLabel value="MinStock:" for="minStock" />
            <p:spinner id="minStock" value="#{productController.product.minStock}" min="1" 
                       title="MinStock" required="true" requiredMessage="The Id field is required."/>
            <p:outputLabel value="MaxStock:" for="maxStock" />
            <p:spinner id="maxStock" value="#{productController.product.maxStock}" min="2"
                       title="MaxStock" required="true" requiredMessage="The Id field is required."/>
            <f:facet name="footer">  
                <p:commandButton value="Guardar" update="@form" action="#{productController.saveOrUpdateProduct()}"/>
                <p:commandButton value="Cancelar" process="@none" />
            </f:facet>  
        </p:panelGrid>

        
    </h:form>



</ui:composition>
